<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
		<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">       
		<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
		<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
		<title>Listado Ventas</title>
    </head>
    <body class="container">
        <%@include file="../../opciones.jsp"%>
        <h1>Listado de Ventas</h1>
        <table id="detalle" class="table table-condensed table-bordered table-hover">
                    <tr>
                        <th>CODIGO BOLETA</th>
                        <th>USUARIO</th>
                        <th>FECHA</th>
                        <th>TOTAL VENTA</th>
                        <th>DESCUENTO</th>
                        <th>ESTADO</th>
                        <th>DETALLE</th>
                        <th>ANULAR</th>
                    </tr>
                    <c:forEach var="fila" items="${lista}">
                        <tbody>
                        <tr>
                            <td><c:out value="${fila.codBoleta}" /></td>
                            <td><c:out value="${fila.nombreUsuario}" /></td>
                            <td><c:out value="${fila.fecha}" /></td>
                            <td><c:out value="${fila.totalVenta}" /></td>
                            <td><c:out value="${fila.descuentos}" /></td>
                            <c:if test="${fila.estado == true}"><td>ACTIVO</td></c:if>
                            <c:if test="${fila.estado == false}"><td>NO ACTIVO</td></c:if>
                            <td> <a id="detalle_eliminar" class="btn btn-success" href="" >Ver Detalle</a></td>
                            <c:if test="${fila.estado == true}"><td><button id="detalle_anular" class="btn btn-danger">Anular</button></td></c:if>
                            
                        </tr>
                        </tbody>
                    </c:forEach>
                </table>
                <script>
                    $('table tbody').on('click','tr button', function(e){
                        fila = $(this).closest('tr');                
                        codigo = fila.find('td').eq(0).text();
                        window.open("<c:url value="/AnularVenta?COD_BOLETA="/>" + codigo +"","_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=300, width=1000, height=500");
                    });
                    $('table tbody').on('click','tr a', function(e){
                        e.preventDefault();
                        fila = $(this).closest('tr');                
                        codigo = fila.find('td').eq(0).text();
                        window.open("<c:url value="/MostrarDetalleBoleta?COD_BOLETA="/>" + codigo +"","_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=300, width=1000, height=500");
                    });
                </script>
    </body>
</html>
